home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-03 | 23.3 KB | 762 lines | [TEXT/MPS ] |
- unit MyPDEF_4_HandlingDialogs;
-
- interface
-
- uses MemTypes, QuickDraw, OsIntf, ToolIntf, PackIntf, MacPrint;
-
- {$D+}
- {$R-}
- {$OV-}
-
- procedure FilePrintDefault(hPrint: THPrint);
- function FilePrStlDialog(hPrint: THPrint): Boolean;
- function FilePrJobDialog(hPrint: THPrint): Boolean;
- function FilePrStlInit(hPrint: THPrint): TPPrDlg;
- function FilePrJobInit(hPrint: THPrint): TPPrDlg;
- function FilePrDlgMain(hPrint: THPrint; pDlgInit: ProcPtr): Boolean;
- function FilePrValidate(hPrint: THPrint): Boolean;
- procedure FilePrJobMerge(hPrintSrc, hPrintDst: THPrint);
- procedure HandleStlItems(theDlg: TPPrDlg; ItemHit: Integer);
- procedure HandleJobItems(theDlg: TPPrDlg; ItemHit: Integer);
- procedure SetDCV(theDialog: DialogPtr; theItem, theValue: Integer);
- function GetDCV(theDialog: DialogPtr; theItem: Integer): Integer;
- procedure SetDINb(theDialog: DialogPtr; theItem: Integer; theValue: Longint);
- function GetDINb(theDialog: DialogPtr; theItem: Integer): Longint;
- function GetDIRect(theDialog: DialogPtr; theItem: Integer): Rect;
- procedure SetDIStr(theDialog: DialogPtr; theItem: Integer; VAR theString: Str255);
- procedure GetDIStr(theDialog: DialogPtr; theItem: Integer; VAR theString: Str255);
- procedure SelDIStr(theDialog: DialogPtr; theItem: Integer);
-
- implementation
-
- const
- ResLoad= $A5E;
- PrintErr= $944;
-
- type
- BoolPtr= ^Boolean;
- IntPtr= ^Integer;
- LongPtr = ^Longint;
- IntArr= array[0..0] of Integer;
- IntArrPtr= ^IntArr;
- IntArrHdl = ^IntArrPtr;
-
- { 2 little inline routines to provide the correct call mechanism, nothing much ! }
- function CallFilePrXXXInit(hPrint: THPrint; theProc: ProcPtr): TPPrDlg;
- inline $205F, $4E90; {MOVEA.L (A7)+,A0 ; JSR (A0)}
-
- procedure CallHandleXXXItems(thePrDlg: TPPrDlg; itemHit: Integer; pItemProc: ProcPtr);
- inline $205F, $4E90; {MOVEA.L (A7)+,A0 ; JSR (A0)}
-
- procedure FilePrintDefault(hPrint: THPrint);
- { the default in is the resource PREC 0, and we also initialize some important fields }
- var
- theDefault: THPrint;
- resLoadStatus: Boolean;
-
- begin
- resLoadStatus := BoolPtr(ResLoad)^;
- if not resLoadStatus then SetResLoad(true);
- theDefault := THPrint(GetResource('PREC', 0));
- if not resLoadStatus then SetResLoad(false);
- if theDefault = nil then
- begin
- IntPtr(PrintErr)^ := -192;
- exit(FilePrintDefault);
- end;
- hPrint^^ := theDefault^^;
- hPrint^^.prJob.iCopies := 1;
- hPrint^^.prJob.pIdleProc := nil;
- hPrint^^.prJob.pFileName := nil;
- hPrint^^.prJob.iFileVol := 0;
- hPrint^^.prJob.bFileVers := 0;
- if StripAddress(Ptr(hPrint^)) <> StripAddress(Ptr(theDefault^)) then
- ReleaseResource(Handle(theDefault));
- end;
-
- { for the 2 following routines, see Inside Macintosh vol. V and the relevant Technical Notes }
-
- function FilePrStlDialog(hPrint: THPrint): Boolean;
- begin
- FilePrStlDialog := FilePrDlgMain(hPrint, @FilePrStlInit);
- end;
-
- function FilePrJobDialog(hPrint: THPrint): Boolean;
- begin
- FilePrJobDialog := FilePrDlgMain(hPrint, @FilePrJobInit);
- end;
-
- { 2 filter routines for the 3 dialogs: Style, Job and Options to set the Numeric Edit Fields right ! }
-
- function FilterNumPrStlAndJob(theDialog: DialogPtr; VAR theEvent: EventRecord; VAR ItemHit: Integer): Boolean;
- begin
- FilterNumPrStlAndJob := false;
- if theEvent.what in [keyDown, autoKey] then
- if Band(theEvent.message, charCodeMask) in [$03, $0D] then
- begin
- ItemHit := 1;
- FilterNumPrStlAndJob := true;
- exit(FilterNumPrStlAndJob);
- end;
- if theEvent.what in [keyDown, autoKey] then
- if not (Band(theEvent.message, charCodeMask) in [$08, $09, $30..$39]) then
- begin
- SysBeep(1);
- FilterNumPrStlAndJob := true;
- ItemHit := -1;
- exit(FilterNumPrStlAndJob);
- end;
- end;
-
- function FilterNumOptions(theDialog: DialogPtr; VAR theEvent: EventRecord; VAR ItemHit: Integer): Boolean;
- begin
- FilterNumOptions := false;
- if theEvent.what in [keyDown, autoKey] then
- if Band(theEvent.message, charCodeMask) in [$03, $0D] then
- begin
- ItemHit := 1;
- FilterNumOptions := true;
- exit(FilterNumOptions);
- end;
- if theEvent.what in [keyDown, autoKey] then
- if (DialogPeek(theDialog)^.editField + 1) = 29 then
- if not (Band(theEvent.message, charCodeMask) in [$08, $09, $30..$39]) then
- begin
- SysBeep(1);
- FilterNumOptions := true;
- ItemHit := -1;
- exit(FilterNumOptions);
- end;
- end;
-
- function FilePrStlInit(hPrint: THPrint): TPPrDlg;
- { we initialize the dialog items with the right settings coming from hPrint }
- var
- theDlg, aDlg: TPPrDlg;
- i: Integer;
- theRect: Rect;
-
- begin
- FilePrStlInit := nil;
- theDlg := TPPrDlg(NewPtr(sizeof(TPrDlg)));
- if theDlg = nil then
- begin
- IntPtr(PrintErr)^ := iMemFullErr;
- exit(FilePrStlInit);
- end;
- with theDlg^ do
- begin
- aDlg := TPPrDlg(GetNewDialog(-8192, Ptr(theDlg), Pointer(-1)));
- if aDlg = nil then
- begin
- IntPtr(PrintErr)^ := -192;
- DisposPtr(Ptr(theDlg));
- exit(FilePrStlInit);
- end;
- SetDCV(DialogPtr(theDlg), 6, Ord(hPrint^^.printX[1] = 0));
- SetDCV(DialogPtr(theDlg), 7, Ord(hPrint^^.printX[1] = 1));
- SetDCV(DialogPtr(theDlg), 8, Ord(hPrint^^.printX[1] = 2));
- SetDINb(DialogPtr(theDlg), 13, hPrint^^.printX[2]);
- SetDINb(DialogPtr(theDlg), 20, hPrint^^.printX[3]);
- SetDINb(DialogPtr(theDlg), 21, hPrint^^.printX[4]);
- SetDCV(DialogPtr(theDlg), 22, Ord(hPrint^^.printX[5] = 0));
- SetDCV(DialogPtr(theDlg), 23, Ord(hPrint^^.printX[5] = 1));
- SetDCV(DialogPtr(theDlg), 24, Ord(hPrint^^.printX[5] = 2));
- if hPrint^^.printX[1] <> 2 then
- for i := 17 to 24 do HideDItem(DialogPtr(theDlg), i);
- pFltrProc := @FilterNumPrStlAndJob;
- pItemProc := @HandleStlItems;
- hPrintUsr := hPrint;
- ShowWindow(GrafPtr(theDlg));
- DrawDialog(GrafPtr(theDlg));
- SetPort(GrafPtr(theDlg));
- if hPrint^^.printX[6] = 0
- then theRect := GetDIRect(DialogPtr(theDlg), 9)
- else theRect := GetDIRect(DialogPtr(theDlg), 10);
- lUser1 := hPrint^^.printX[6];
- InvertRect(theRect);
- ValidRect(GrafPtr(theDlg)^.portRect);
- end;
- FilePrStlInit := theDlg;
- end;
-
- function FilePrJobInit(hPrint: THPrint): TPPrDlg;
- { we initialize the dialog items with the right settings coming from hPrint }
- var
- aDlg, theDlg: TPPrDlg;
- theWorld: SysEnvRec;
- CodeErr: OsErr;
-
- begin
- theDlg := TPPrDlg(NewPtr(sizeof(TPrDlg)));
- if theDlg = nil then
- begin
- IntPtr(PrintErr)^ := iMemFullErr;
- exit(FilePrJobInit);
- end;
- with theDlg^ do
- begin
- aDlg := TPPrDlg(GetNewDialog(-8191, Ptr(theDlg), Pointer(-1)));
- if aDlg = nil then
- begin
- IntPtr(PrintErr)^ := -192;
- DisposPtr(Ptr(theDlg));
- exit(FilePrJobInit);
- end;
- CodeErr := SysEnvirons(1, theWorld);
- if not theWorld.hasColorQD then
- begin
- HideDItem(DialogPtr(theDlg), 14); HideDItem(DialogPtr(theDlg), 15);
- hPrint^^.printX[14] := 1;
- end;
- SetDCV(DialogPtr(theDlg), 5, Ord(hPrint^^.printX[7] = 0));
- SetDCV(DialogPtr(theDlg), 6, Ord(hPrint^^.printX[7] = 1));
- SetDCV(DialogPtr(theDlg), 12, Ord(hPrint^^.printX[8] = 0));
- SetDCV(DialogPtr(theDlg), 13, Ord(hPrint^^.printX[8] = 1));
- SetDCV(DialogPtr(theDlg), 14, Ord(hPrint^^.printX[14] = 0));
- SetDCV(DialogPtr(theDlg), 15, Ord(hPrint^^.printX[14] = 1));
- pFltrProc := @FilterNumPrStlAndJob;
- pItemProc := @HandleJobItems;
- hPrintUsr := hPrint;
- ShowWindow(GrafPtr(theDlg));
- SetPort(GrafPtr(theDlg));
- end;
- FilePrJobInit := theDlg;
- end;
-
- function FilePrDlgMain(hPrint: THPrint; pDlgInit: ProcPtr): Boolean;
- { see Inside Macintosh vol. V and the relevant Technical Notes }
- { we preload hPrint with the PREC 1 resource which is the last settings chosen by the user }
- { of course, after the user sets anew the values, we store them in the PREC 1 resource }
-
- { Note: some applications pay attention to the PREC 1 mechanism, but not all of them }
- var
- thePrDlg: TPPrDlg;
- SavePort: GrafPtr;
- itsBox: Rect;
- itemHit: Integer;
- resLoadStatus: Boolean;
- theDefault: THPrint;
-
- begin
- GetPort(SavePort);
- resLoadStatus := BoolPtr(ResLoad)^;
- if not resLoadStatus then SetResLoad(true);
- theDefault := THPrint(GetResource('PREC', 1));
- if not resLoadStatus then SetResLoad(false);
- if theDefault <> nil then hPrint^^ := theDefault^^;
- thePrDlg := CallFilePrXXXInit(hPrint, pDlgInit);
- with thePrDlg^ do
- begin
- fDone := false;
- fDoIt := false;
- itsBox := GetDIRect(DialogPtr(thePrDlg), 1);
- PenSize(3, 3);
- InsetRect(itsBox, -4, -4);
- FrameRoundRect(itsBox, 16, 16);
- while not fDone do
- begin
- ModalDialog(pFltrProc, itemHit);
- CallHandleXXXItems(thePrDlg, itemHit, pItemProc);
- end;
- SetPort(SavePort);
- CloseDialog(DialogPtr(thePrDlg));
- if fDoIt then { save in PREC 1 }
- begin
- resLoadStatus := BoolPtr(ResLoad)^;
- if not resLoadStatus then SetResLoad(true);
- theDefault := THPrint(GetResource('PREC', 1));
- if not resLoadStatus then SetResLoad(false);
- if theDefault <> nil then
- begin
- theDefault^^ := hPrint^^;
- ChangedResource(Handle(theDefault));
- WriteResource(Handle(theDefault));
- end;
- end;
- FilePrDlgMain := fDoIt;
- DisposPtr(Ptr(thePrDlg));
- end;
- end;
-
- function FilePrValidate(hPrint: THPrint): Boolean;
- { if the signature $5345 (ES) is present in the hPrint, then I consider that the values are ok }
- { else we just load anew the resource PREC 0 }
- { this alogrythm is not the best and could certainly be improved ! }
- var
- theDefault: THPrint;
- resLoadStatus: Boolean;
- valid: Boolean;
- i: Integer;
-
- begin
- resLoadStatus := BoolPtr(ResLoad)^;
- if not resLoadStatus then SetResLoad(true);
- theDefault := THPrint(GetResource('PREC', 0));
- if not resLoadStatus then SetResLoad(false);
- if theDefault = nil then
- begin
- IntPtr(PrintErr)^ := -192;
- exit(FilePrValidate);
- end;
-
- valid := (hPrint^^.printX[9] = $5345);
- if not valid then hPrint^^ := theDefault^^;
- if StripAddress(Ptr(hPrint^)) <> StripAddress(Ptr(theDefault^)) then
- ReleaseResource(Handle(theDefault));
-
- hPrint^^.prJob.iCopies := 1;
- hPrint^^.prJob.pIdleProc := nil;
- hPrint^^.prJob.pFileName := nil;
- hPrint^^.prJob.iFileVol := 0;
- hPrint^^.prJob.bFileVers := 0;
-
- FilePrValidate := valid;
- end;
-
- procedure FilePrJobMerge(hPrintSrc, hPrintDst: THPrint);
- { do we really want to manage this ? }
- { in fact, maybe we should in the case of a physical device printer driver }
- begin
- end;
-
- procedure HandleStlItems(theDlg: TPPrDlg; ItemHit: Integer);
- { ok ! Here's just some dialog managing, and I won't bother you with the obvious ! }
- var
- i, j, k: Integer;
- theRect: Rect;
- valid: Boolean;
- height, width, rate: Longint;
- optDlg: DialogPtr;
- sigHandle: Handle;
- sigTEXT, sigPICT: OsType;
- aStr: Str255;
- sigTab: array[1..14] of OsType;
-
- procedure RefreshDialog;
- { redraw the frame around the ok button, and pay attention to the orientation icons }
- begin
- DrawDialog(DialogPtr(theDlg));
- theRect := GetDIRect(DialogPtr(theDlg), 1);
- PenSize(3, 3);
- InsetRect(theRect, -4, -4);
- FrameRoundRect(theRect, 16, 16);
-
- if theDlg^.lUser1 = 0
- then theRect := GetDIRect(DialogPtr(theDlg), 9)
- else theRect := GetDIRect(DialogPtr(theDlg), 10);
- InvertRect(theRect);
- ValidRect(GrafPtr(theDlg)^.portRect);
- end;
-
- begin
- with theDlg^ do
- case ItemHit of
- ok: begin
- valid := true;
- if GetDCV(DialogPtr(theDlg), 6) = 1 then
- if lUser1 = 0
- then begin width := 538; height := 781 end
- else begin width := 781; height := 538 end
- else if GetDCV(DialogPtr(theDlg), 7) = 1 then
- if lUser1 = 0
- then begin width := 552; height := 730 end
- else begin width := 730; height := 552 end
- else
- begin
- width := GetDINb(DialogPtr(theDlg), 20);
- height := GetDINb(DialogPtr(theDlg), 21);
- if lUser1 = 1 then
- begin i := width; width := height; height := i; end;
- if GetDCV(DialogPtr(theDlg), 22) = 1 then
- begin
- width := (width * 72) div 1000;
- height := (height * 72) div 1000;
- end
- else if GetDCV(DialogPtr(theDlg), 23) = 1 then
- begin
- width := (width * 720) div 254;
- height := (height * 720) div 254;
- end;
- end;
- rate := GetDINb(DialogPtr(theDlg), 13);
- if (rate > 0) and (rate <= 32767) then
- begin
- width := (width * 100) div rate;
- height := (height * 100) div rate;
- end
- else valid := false;
- if valid then valid := (width <> 0) and (height <> 0);
- if valid then with hPrintUsr^^ do
- begin
- SetRect(rPaper, 0, 0, width, height);
- prInfo.rPage := rPaper;
- prInfoPT.rPage := rPaper;
- prStl.iPageV := (height * 120) div 72;
- prStl.iPageH := (width * 120) div 72;
- if GetDCV(DialogPtr(theDlg), 6) = 1 then printX[1] := 0;
- if GetDCV(DialogPtr(theDlg), 7) = 1 then printX[1] := 1;
- if GetDCV(DialogPtr(theDlg), 8) = 1 then printX[1] := 2;
- printX[2] := GetDINb(DialogPtr(theDlg), 13);
- printX[3] := GetDINb(DialogPtr(theDlg), 20);
- printX[4] := GetDINb(DialogPtr(theDlg), 21);
- if GetDCV(DialogPtr(theDlg), 22) = 1 then printX[5] := 0;
- if GetDCV(DialogPtr(theDlg), 23) = 1 then printX[5] := 1;
- if GetDCV(DialogPtr(theDlg), 24) = 1 then printX[5] := 2;
- printX[6] := lUser1;
- fDone := true;
- fDoIt := true;
- end
- else
- begin
- i := StopAlert(-8160, nil);
- RefreshDialog;
- end;
- end;
- cancel: begin fDone := true; fDoIt := false; end;
- 6: if GetDCV(DialogPtr(theDlg), ItemHit) = 0 then
- begin
- if GetDCV(DialogPtr(theDlg), 8) = 1 then
- for i := 17 to 24 do HideDItem(DialogPtr(theDlg), i);
- SetDCV(DialogPtr(theDlg), 8, 0);
- SetDCV(DialogPtr(theDlg), 7, 0);
- SetDCV(DialogPtr(theDlg), 6, 1);
- end;
- 7: if GetDCV(DialogPtr(theDlg), ItemHit) = 0 then
- begin
- if GetDCV(DialogPtr(theDlg), 8) = 1 then
- for i := 17 to 24 do HideDItem(DialogPtr(theDlg), i);
- SetDCV(DialogPtr(theDlg), 8, 0);
- SetDCV(DialogPtr(theDlg), 7, 1);
- SetDCV(DialogPtr(theDlg), 6, 0);
- end;
- 8: if GetDCV(DialogPtr(theDlg), ItemHit) = 0 then
- begin
- for i := 17 to 24 do ShowDItem(DialogPtr(theDlg), i);
- SetDCV(DialogPtr(theDlg), 8, 1);
- SetDCV(DialogPtr(theDlg), 7, 0);
- SetDCV(DialogPtr(theDlg), 6, 0);
- end;
- 9,10:if lUser1+ItemHit = 10 then
- begin
- theRect := GetDIRect(DialogPtr(theDlg), 9); InvertRect(theRect);
- theRect := GetDIRect(DialogPtr(theDlg), 10); InvertRect(theRect);
- lUser1 := ItemHit-9;
- end;
- 22..24:
- if GetDCV(DialogPtr(theDlg), ItemHit) = 0 then
- begin
- SetDCV(DialogPtr(theDlg), 22, 0);
- SetDCV(DialogPtr(theDlg), 23, 0);
- SetDCV(DialogPtr(theDlg), 24, 0);
- SetDCV(DialogPtr(theDlg), ItemHit, 1);
- end;
- 25: begin { here's the options dialog managing }
- sigHandle := GetResource('STR#', -8193);
- if sigHandle = nil then
- begin
- SysBeep(1);
- exit(HandleStlItems);
- end;
- for i := 1 to 14 do
- begin
- GetIndString(aStr, -8193, i);
- BlockMove(Ptr(Longint(@aStr)+1), @sigTab[i], 4);
- end;
- optDlg := GetNewDialog(-8193, nil, Pointer(-1));
-
- for i := 8 to 15 do SetDCV(optDlg, i, 0);
- for i := 17 to 24 do SetDCV(optDlg, i, 0);
- BlockMove(@hPrintUsr^^.printX[10], @sigTEXT, 4);
- BlockMove(@hPrintUsr^^.printX[12], @sigPICT, 4);
- j := 8; k := 15;
- for i := 1 to 7 do if sigPICT = sigTab[i] then j := i;
- for i := 8 to 14 do if sigTEXT = sigTab[i] then k := i;
- if j = 8 then
- begin
- SetDCV(optDlg, 15, 1);
- aStr[0] := Chr(4);
- BlockMove(@sigPICT, Ptr(Longint(@aStr)+1), 4);
- SetDIStr(optDlg, 16, aStr);
- end
- else SetDCV(optDlg, j+7, 1);
- if k = 15 then
- begin
- SetDCV(optDlg, 24, 1);
- aStr[0] := Chr(4);
- BlockMove(@sigTEXT, Ptr(Longint(@aStr)+1), 4);
- SetDIStr(optDlg, 25, aStr);
- end
- else SetDCV(optDlg, k+9, 1);
-
- SetDINb(optDlg, 29, LongPtr(@hPrintUsr^^.printX[15])^);
- SetDCV(optDlg, 31, ord(hPrintUsr^^.printX[17] = 0));
-
- ShowWindow(optDlg);
- SetPort(optDlg);
- theRect := GetDIRect(DialogPtr(optDlg), 1);
- PenSize(3, 3);
- InsetRect(theRect, -4, -4);
- FrameRoundRect(theRect, 16, 16);
- SetPort(GrafPtr(theDlg));
-
- repeat
- ModalDialog(@FilterNumOptions, ItemHit);
- case ItemHit of
- ok:begin
- if j = 8 then
- begin
- GetDIStr(optDlg, 16, aStr);
- if Length(aStr) <> 4 then
- begin
- i := StopAlert(-8161, nil);
- SetPort(optDlg);
- theRect := GetDIRect(DialogPtr(optDlg), 1);
- PenSize(3, 3);
- InsetRect(theRect, -4, -4);
- FrameRoundRect(theRect, 16, 16);
- SetPort(GrafPtr(theDlg));
- SelDIStr(optDlg, 16);
- ItemHit := -1;
- end;
- end;
- if k = 15 then
- begin
- GetDIStr(optDlg, 25, aStr);
- if Length(aStr) <> 4 then
- begin
- i := StopAlert(-8161, nil);
- SetPort(optDlg);
- theRect := GetDIRect(DialogPtr(optDlg), 1);
- PenSize(3, 3);
- InsetRect(theRect, -4, -4);
- FrameRoundRect(theRect, 16, 16);
- SetPort(GrafPtr(theDlg));
- SelDIStr(optDlg, 25);
- ItemHit := -1;
- end;
- end;
- if GetDINb(optDlg, 29) <= 0 then
- begin {this should never happen, but Murphy lives…}
- SysBeep(1);
- SelDIStr(optDlg, 29);
- ItemHit := -1;
- end;
- end;
- 8..15:if j <> ItemHit-7 then
- begin
- SetDCV(optDlg, j+7, 0);
- j := ItemHit-7;
- SetDCV(optDlg, j+7, 1);
- end;
- 17..24:if k <> ItemHit-9 then
- begin
- SetDCV(optDlg, k+9, 0);
- k := ItemHit-9;
- SetDCV(optDlg, k+9, 1);
- end;
- 16,25:begin
- GetDIStr(optDlg, ItemHit, aStr);
- if Length(aStr) > 4 then
- begin
- SysBeep(1);
- aStr[0] := Chr(4);
- SetDIStr(optDlg, ItemHit, aStr);
- end;
- end;
- 31: SetDCV(optDlg, ItemHit, 1 - GetDCV(optDlg, ItemHit));
- end;
- until ItemHit in [ok, cancel];
- if ItemHit = ok then
- begin
- if j = 8 then
- begin
- GetDIStr(optDlg, 16, aStr);
- BlockMove(Ptr(Longint(@aStr)+1), @hPrintUsr^^.printX[12], 4);
- end
- else BlockMove(@sigTab[j], @hPrintUsr^^.printX[12], 4);
- if k = 15 then
- begin
- GetDIStr(optDlg, 25, aStr);
- BlockMove(Ptr(Longint(@aStr)+1), @hPrintUsr^^.printX[10], 4);
- end
- else BlockMove(@sigTab[k], @hPrintUsr^^.printX[10], 4);
- rate := GetDINb(optDlg, 29);
- BlockMove(@rate, @hPrintUsr^^.printX[15], 4);
- hPrintUsr^^.printX[17] := 1 - GetDCV(optDlg, 31);
- end;
- DisposDialog(optDlg);
- ReleaseResource(sigHandle);
-
- RefreshDialog;
- end;
- 26: begin { here's the help dialog managing }
- optDlg := GetNewDialog(-8194, nil, Pointer(-1));
-
- for i := 6 to 11 do HideDItem(optDlg, i);
- ShowWindow(optDlg);
- DrawDialog(optDlg);
- SetPort(optDlg);
- ValidRect(optDlg^.portRect);
- TextFont(Geneva);
- TextSize(9);
- for i := 6 to 11 do ShowDItem(optDlg, i);
- theRect := GetDIRect(DialogPtr(optDlg), 1);
- PenSize(3, 3);
- InsetRect(theRect, -4, -4);
- FrameRoundRect(theRect, 16, 16);
- SetPort(GrafPtr(theDlg));
-
- repeat
- ModalDialog(nil, ItemHit);
- until ItemHit = ok;
- DisposDialog(optDlg);
-
- RefreshDialog;
- end;
- end;
- end;
-
- procedure HandleJobItems(theDlg: TPPrDlg; ItemHit: Integer);
- { ok ! Here's just some dialog managing, and I won't bother you with the obvious ! }
- begin
- with theDlg^ do
- case ItemHit of
- ok:with hPrintUsr^^ do
- begin
- if GetDCV(DialogPtr(theDlg), 5) = 0 then
- begin
- prJob.iFstPage := GetDINb(DialogPtr(theDlg), 7);
- prJob.iLstPage := GetDINb(DialogPtr(theDlg), 9);
- printX[7] := 1;
- end
- else
- begin
- prJob.iFstPage := 1;
- prJob.iLstPage := 9999;
- printX[7] := 0;
- end;
- if GetDCV(DialogPtr(theDlg), 12) = 0
- then printX[8] := 1
- else printX[8] := 0;
- if GetDCV(DialogPtr(theDlg), 14) = 0
- then printX[14] := 1
- else printX[14] := 0;
- fDone := true; fDoIt := true;
- end;
- cancel: begin fDone := true; fDoIt := false; end;
- 5, 6: if GetDCV(DialogPtr(theDlg), ItemHit) = 0 then
- begin
- SetDCV(DialogPtr(theDlg), ItemHit, 1);
- SetDCV(DialogPtr(theDlg), 11 - ItemHit, 0);
- end;
- 7, 9: if GetDCV(DialogPtr(theDlg), 6) = 0 then
- begin
- SetDCV(DialogPtr(theDlg), 6, 1);
- SetDCV(DialogPtr(theDlg), 5, 0);
- end;
- 12,13:if GetDCV(DialogPtr(theDlg), ItemHit) = 0 then
- begin
- SetDCV(DialogPtr(theDlg), ItemHit, 1);
- SetDCV(DialogPtr(theDlg), 25 - ItemHit, 0);
- end;
- 14,15:if GetDCV(DialogPtr(theDlg), ItemHit) = 0 then
- begin
- SetDCV(DialogPtr(theDlg), ItemHit, 1);
- SetDCV(DialogPtr(theDlg), 29 - ItemHit, 0);
- end;
- end;
- end;
-
- { here are some useful and convenient routines to ease the dialog managing }
-
- procedure SetDCV(theDialog: DialogPtr; theItem, theValue: Integer);
- var
- theType: Integer;
- theHandle: Handle;
- theRect: Rect;
-
- begin
- GetDItem(theDialog, theItem, theType, theHandle, theRect);
- SetCtlValue(ControlHandle(theHandle), theValue);
- end;
-
- function GetDCV(theDialog: DialogPtr; theItem: Integer): Integer;
- var
- theType: Integer;
- theHandle: Handle;
- theRect: Rect;
-
- begin
- GetDItem(theDialog, theItem, theType, theHandle, theRect);
- GetDCV := GetCtlValue(ControlHandle(theHandle));
- end;
-
- procedure SetDINb(theDialog: DialogPtr; theItem: Integer; theValue: Longint);
- var
- theType: Integer;
- theHandle: Handle;
- theRect: Rect;
- theStr: Str255;
-
- begin
- GetDItem(theDialog, theItem, theType, theHandle, theRect);
- NumToString(theValue, theStr);
- SetIText(theHandle, theStr);
- end;
-
- function GetDINb(theDialog: DialogPtr; theItem: Integer): Longint;
- var
- theType: Integer;
- theHandle: Handle;
- theRect: Rect;
- theStr: Str255;
- theValue: Longint;
-
- begin
- GetDItem(theDialog, theItem, theType, theHandle, theRect);
- GetIText(theHandle, theStr);
- StringToNum(theStr, theValue);
- GetDINb := theValue;
- end;
-
- function GetDIRect(theDialog: DialogPtr; theItem: Integer): Rect;
- var
- theType: Integer;
- theHandle: Handle;
- theRect: Rect;
-
- begin
- GetDItem(theDialog, theItem, theType, theHandle, theRect);
- GetDIRect := theRect;
- end;
-
- procedure SetDIStr(theDialog: DialogPtr; theItem: Integer; VAR theString: Str255);
- var
- theType: Integer;
- theHandle: Handle;
- theRect: Rect;
-
- begin
- GetDItem(theDialog, theItem, theType, theHandle, theRect);
- SetIText(theHandle, theString);
- end;
-
- procedure GetDIStr(theDialog: DialogPtr; theItem: Integer; VAR theString: Str255);
- var
- theType: Integer;
- theHandle: Handle;
- theRect: Rect;
-
- begin
- GetDItem(theDialog, theItem, theType, theHandle, theRect);
- GetIText(theHandle, theString);
- end;
-
- procedure SelDIStr(theDialog: DialogPtr; theItem: Integer);
- begin
- SelIText(theDialog, theItem, 0, 32767);
- end;
-
- end.
-